<template>
  <div class="video-player">
    <video :src="videoUrl" controls autoplay class="video-element">您的浏览器不支持 video 标签。</video>
    <div class="video-details">
      <h3>{{ video.title }}</h3>
      <p>{{ video.description }}</p>
      <p><strong>发布日期：</strong>{{ formattedDate }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: 'VideoPlayer',
  props: {
    video: {
      type: Object,
      required: true,
    },
  },
  computed: {
    videoUrl() {
      return `http://127.0.0.1:8000/api/xhs/test/?note_id=${this.video.id}`;
    },
    formattedDate() {
      return new Date(this.video.publish_date).toLocaleDateString();
    },
  },
};
</script>

<style scoped>
.video-player {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.video-element {
  width: 100%;
  max-width: 800px;
  height: auto;
  border-radius: 8px;
}

.video-details {
  margin-top: 16px;
  width: 100%;
  max-width: 800px;
}

.video-details h3 {
  margin-bottom: 8px;
  font-size: 20px;
  color: #333;
}

.video-details p {
  margin: 4px 0;
  color: #666;
  font-size: 14px;
}
</style>
